fileName = 'birthday.txt'
try:
    file = open(fileName, 'r')
except FileNotFoundError:
    print(fileName, '文件不存在')
else:
    print(fileName, '文件有', len(file.readline()), '行')
    file.close()


fileName = 'integer.txt'
try:
    file = open(fileName, 'a')
    data = int(input('请输入一个整数'))
    file.write(str(data))
except Exception as e:
    print(e)
finally:
    print('关闭文件')
    file.close()